package TestExercises01;

//需求：将整数上的每一位都添加到数组中（结合前面的test06数字加密）
public class test07 {
    public static void main(String[] args) {
        int number = 1983;
        int number1 = number;
        int number2 = number;
        int count = 0;
        while (number1 != 0) {
            number1 = number1 / 10;
            count++;//去掉一位计数器就自增一次
        }
        System.out.println("整数长度为：" + count);


        int[] arr = new int[count];


        for (int i = arr.length - 1; number2 != 0; i--) {
            arr[i] = number2 % 10;
            number2 = number2 / 10;
        }
        System.out.print("数组元素为：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
